<?php

$modules = require __DIR__ . '/modules.php';

$params = array_merge(
    require __DIR__ . '/params.php',
    require __DIR__ . '/params-local.php'
);

return [
    //应用ID
    'id' => 'backend',
    //版本
    'version' => '1.1.0',
    //语言
    'language' => 'zh-CN',
    //时区
    'timeZone' => 'Asia/Shanghai',
    //项目路径
    'basePath' => dirname(__DIR__),
    //别名
    'aliases' => [
        '@app' => dirname(__DIR__),
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    //控制器命名空间
    'controllerNamespace' => 'app\modules',
    //分组配置
    'group' => [
        'api' => 'yii\api\Application',
        'admin' => 'yii\web\Application',
    ],
    //默认路由
    'defaultRoute' => 'core/site/index',
    //启动引导
    'bootstrap' => ['log',\app\common\service\InitBootstrap::class,'sookie\bootstraps\AnalysisBootstrap'],
//    'catchAll' => [
//        'test/test/index',
//        'content' => '升级维护中.....',
//    ],
    //全局参数
    'params' => $params,
    //框架模块
    'modules' => $modules,
    //组件配置
    'components' => [
        'user' => [
            'identityClass' => 'sookie\auth\models\Adminuser',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-admin', 'httpOnly' => true],
            //设置登录页面的地址
            'loginUrl' => ['core/site/login'],
        ],
        'cache' => [
            'class' => yii\redis\Cache::className()
        ],
        'jwt' => [
            'class' => 'sookie\auth\components\Jwt',
            'key' => 'secret',
            'valid_time' => 3600000,
            'signer' => \Lcobucci\JWT\Signer\Hmac\Sha256::class,
            'sadd_key' => 'jwt'
        ],
        'captcha' => [
            'class' => 'sookie\auth\components\Captcha',
            'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            'backColor'=>0x000000,//背景颜色
            'maxLength' => 4, //最大显示个数
            'minLength' => 4,//最少显示个数
            'padding' => 5,//间距
            'height' => 40,//高度
            'width' => 130,  //宽度
            'foreColor'=>0xffffff,     //字体颜色
            'offset'=>4,//设置字符偏移量 有效果
        ],
        'uploader' => [
            'class' => 'sookie\uploader\FileUploaderComponent',
            'allowExt' => '*',
            'basePath' => '@webroot/static/uploader',
            'temp_path' => '@webroot/static/temp',
            'chunk_path' => '@webroot/static/chunks',
            'web_path' => '@web/static/uploader',
            'db' => 'db',
            'table' => 'sys_upload_files'
        ],
        'db' =>  require __DIR__ . '/db.php',
        'caching' => [
            'class' => 'sookie\caching\CacheHandler',
            'autoUpdateKey' => 'youhappyisgood',
            'table' => 'sys_cache_mapping',
            'dbLink' => 'db'
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => YII_ENV == 'dev' ? 'yii\log\FileTarget' : 'yii\log\DbTarget',
                    'levels' => YII_ENV == 'dev' ? ['error', 'warning'] : ['error'],
                ],
            ],
        ],
    ]
];
